$(document).ready(function() {
  // echo
  util.echo();
  // img delay
  $.each($('.img-delay'), (index, item) => {
    const $item = $(item);
    const src = $item.data('src');
    const width = $item.data('width');
    const height = $item.data('height');
    $item.attr('src', util.combineImageUrl(src, width, height));
    $(item).removeClass('img-delay');
  });
});

$(document).on('echo-ready', function() {
  // hotload file
  if (env.site.hotloadFile && !util.user.op.anonymous) {
    window.setTimeout(() => {
      const subscribePath = `/a/cms/hotloadFile/${env.site.hotloadFile}`;
      util.io.subscribe(subscribePath, () => {
        location.reload(true);
      }, null);
    }, 0);
  }
});
